package motodev.app;

import java.util.TimerTask;

public class Clock extends TimerTask{

    private int timeLeft = 60;//default time
    private boolean pause = false;

    /** Creates a new instance of GameClock */
    Connect4 iMS = null;

    /**
     * Constructor that creates a new Clock.
     * @param m
     */
    public Clock(Connect4 m) {
    	iMS = m;
    }

    /**
     * Constructor that creates a clock with an integer value.
     * @param value
     */
    public Clock(int value){
        timeLeft = value;
    }

    /**
     * Checks for a received message.
     */
    public void run(){
    	
//    	if (!Connect4.opponentHasKey) {
//    	
//	    	// Broadcast Y component of key
//	    	if (Connect4.isBroadcastingY) {
//	    		iMS.broadcastY();
//	    	}
//	    	
//	    	if (Connect4.iHaveKey) {
//	    		byte[] ack = {'a', 'c', 'k'};
//	  			RMS.send_cmd(ack);
//	    	}
//    	}
    	
    	System.out.print(".");
    	iMS.received_cmd(RMS.get_cmd());
    }

    /**
     * Pauses.
     */
    public void pause(){
        pause = true;
    }

    /**
     * Resumes
     */
    public void resume(){
        pause = false;
    }

    /**
     * Gets the time left.
     * @return Time left
     */
    public int getTimeLeft(){
        return timeLeft;
    }

    /**
     * Sets the amount of time
     * @param _value Amount of time to be set
     */
    public void setTimeLeft(int _value){
        this.timeLeft = _value;
    }
	
}